package framework

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/theme"
	"fyne.io/fyne/v2/widget"
	"go-CodeToolUi/core"
	"go-CodeToolUi/inner_resources/_icon_"
)

var TopJieGou = topStructure()

func topStructure() fyne.CanvasObject {
	toolbar := widget.NewToolbar(
		widget.NewToolbarAction(theme.SettingsIcon(), func() {
			//判断configWindow是否存在
			if core.ConfigWindow != nil {
				core.ConfigWindow.Show()
				return
			}
			var config__ = core.AppCore.NewWindow("配置")
			config__.SetIcon(_icon_.ResourceIconPng)
			config__.CenterOnScreen()
			config__.Resize(fyne.NewSize(800, 700))
			border := core.GetComponent("config")
			config__.SetContent(border)
			config__.SetOnClosed(func() {
				core.ConfigWindow = nil
			})
			config__.Show()
			core.ConfigWindow = config__

		}),
	)
	return toolbar
}
